<?php
namespace Taxx\UserBundle\Forms;

use Taxx\KernelBundle\Model\FormBuilder\FormBuilder;
use Taxx\KernelBundle\Model\Utils\JsonTranslator;
use Taxx\KernelBundle\Model\Utils\PublicFileRegistry;

class LoginForm 
{
    private $builder;
    
    public function __construct($language) 
    {
        $translations = JsonTranslator::parseTranslationFile(PublicFileRegistry::getFilePath("user_translations"));
        $labels = $translations['form_labels'][$language];
        $this->builder = new FormBuilder();
        $this->builder->setLegend($labels['login']);
        $this->builder->addInputField('login_username', $labels['username'], array('name'=>'username', 'type' => 'text'));
        $this->builder->addInputField('login_password', $labels['password'], array('name'=>'password', 'type' => 'password'));
        $this->builder->addButton('register_btn', $labels['login_btn'], array('type'=>'button', 'onclick'=>'checkLoginForm(\''.$language.'\')'));
    }
    
    public function getForm($action)
    {
        return $this->builder->getForm('loginForm', array('action'=>$action, 'method'=>'post'));
    }
}

?>
